serde-intermediate
serde-intermediate
Intermediate representation for Rust's Serde serialization
Table of contents
Goals
This crate was made to solve these particular problems:
-
Provide untyped (obviously "fat") runtime value representation used as exchange data ready to be deserialized on demand into typed data, for data where serializable tagged trait objects don't work on taret platforms.
Example: data stored in interpreted language runtime value.
-
Support for more interpreted than exact data conversion (if it quacks like a duck, treat it like a duck) which is default behavior, optionally force to read exact layout stored in value.
Example: more forgiving convertion between unrelated data formats.
-
Support for versioning (allow to produce diffs between two versions of data, that can be later patched on demand).
Example: Game assets content difference for DLC or any episodic content usage; editor UI sending only changes to the game runtime to patch what actually changed in the world (instead of sending entire serialized object state).
-
Support for tagged intermediate data.
Example: Game asset stores data of type that is decided at runtime (associated tag gives hint what type its layout represents).
Installation
-
Core crate with most important
Intermediate
andReflectIntermediate
types:[] = "*"
If you prefer to compile without
ReflectIntermediate
derive macro (derive
feature adds derive macros and is enabled by default):[] = { = "*", = false }
-
Crate that adds support for tagged intermediate value (to embed tagged
Intermediate
in other serializable data withTaggedIntermediate
type):[] = "*"
Same as with core crate, you can exclude
ReflectIntermediate
from compilation:[] = { = "*", = false }
Examples
Serialize/deserialize:
use SystemTime;
use ;
let data = Person ;
let serialized = to_intermediate.unwrap;
let deserialized = from_intermediate.unwrap;
assert_eq!;
More elaborate problems and solutions:
- Versioning (diff/patch) (test_versioning)
- Conversion between data layouts (test_transform)
- DLC / episodic content (test_dlcs)
- Data change communication between game and editor (test_editor_communication)
License: MIT OR Apache-2.0